#!/usr/bin/python
# -*- coding:UTF8 -*-


import requests

header = {
    "Authorization": "APPCODE 36a6d64593884af1971d218d14a23f9d"
}

url = "http://jisutqybmf.market.alicloudapi.com/weather/query'"

querdata = {
    "city": "上海"
}

r = requests.get(
    url=url,
    headers=header,
    params=querdata
)

print(r.status_code)
print(r.text)

# 发送post 请求

url = "http://47.100.175.62:3000/api/v1/topics"
bodydata = {
    "accesstoken": "f68cf811-b2b0-48f2-80e9-ff98a37a30f0",
    "title": "helloworld",
    "tab": "ask",
    "content": "xxxxxxxx"
}
# 当数据传个json字段的时候r = requests.post(url=url,json=bodydata) ,发出去的请求，请求头的格式是是 application/x-www-form-urlencoded
r = requests.post(url=url, data=bodydata)
# 当数据传个json字段的时候r = requests.post(url=url,json=bodydata) ,发出去的请求，请求头的格式是是 application/json
# r = requests.post(url=url, json=bodydata)

print(r.json())
print(r.status_code)
print(r.request.headers['Content-Type'], r.request.headers)

